; *** Seega
; *** Copyright 1998-2002 Zillions Development
; v.2.0

; You need to purchase Zillions of Games to load this rules file
; Visit the Zillions web site at http://www.zillions-of-games.com

(version "2.0")
(translate
("Seega" "夹吃棋") ("High Jump" "跳吃棋")
)
(define check-for-capture
    (if (enemy? $1) ; Is there an enemy this direction?
    	$1
		(if (and (not-position? c3) (friend? $1))
			(set-flag capture-found true)
            capture
		)
		back
	)
)
(define shift-orthoganally 
   ($1
    (verify empty?)
    (set-flag capture-found false)
    mark
    (check-for-capture $1)
    (check-for-capture $2)
    (check-for-capture $3)
    (if (flag? capture-found) (add-partial capturing-move) else add)
   )
)
(define shift-and-capture 
   ($1
    (verify empty?)
    (set-flag capture-found false)
    mark
    (check-for-capture $1)
    (check-for-capture $2)
    (check-for-capture $3)
    (if (flag? capture-found) (add-partial capturing-move))
   )
)

(game
    (title "Seega")
    (description "每方持有棋子各12个。空盘开局，每方落子两枚。不得落在棋盘正中间。之后才能移动棋子。\\
	棋子可横或纵向移动一格。若走棋之后恰好包夹对方一个棋子，则该棋子被吃。可以连续吃子。若棋子走到棋盘中心，则这个棋子不能被吃。\\吃光对手，或使对手剩下1个棋子为胜。")
    (history "Seega is an ancient Egyptian game which has since spread to
          North and West Africa.  Several boards have been cut into the
          stones of the summit of the Great Pyramid by Arabs who served
          as guides to travellers.   It is still played today in Somalia,
          Senegal, and other countries in Africa.   Larger variants are
          sometimes played on 7x7 or 9x9 boards.   The method of capture in Seega,
          called `interception` or `custodian` capture, is one of the oldest forms
          found in board games.")
    (strategy "It is best to get as many outside squares as possible, as
          these are less vulnerable to capture than interior ones.")
    (option "include off-pieces" true)
    (option "pass turn" forced)
    (option "prevent flipping" 2)
    (players Black White)
    (turn-order
        Black Black White White
        Black Black White White
        Black Black White White
        Black Black White White
        Black Black White White
        Black Black White White
        repeat White Black        
    )
    (move-priorities place-stone move-stone capturing-move)
    (board
        (image "images\Seega\Seega.bmp")
        (grid
            (start-rectangle 1 1 55 55)
            (dimensions ;5x5
                ("a/b/c/d/e" (54 0)) ; columns
                ("5/4/3/2/1" (0 54)) ; rows
			)
			(directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0))
		)
		
	)
    (board-setup
        (White (Kelb off 12))
        (Black (Kelb off 12)))
    (piece
        (name Kelb)
	    (image White "images\Seega\WStone.bmp"
		       Black "images\Seega\BStone.bmp")
		(help "棋子：落子阶段每次落2枚，走子阶段直1格，夹吃")
        (drops
            (move-type place-stone)
            ((verify (and empty? (not-position? c3))) add)
        )
        (moves
            (move-type move-stone)
             (shift-orthoganally n w e)
             (shift-orthoganally s w e)
             (shift-orthoganally e n s)
             (shift-orthoganally w n s)
            (move-type capturing-move)
			 (shift-and-capture n w e)
             (shift-and-capture s w e)
             (shift-and-capture e n s)
             (shift-and-capture w n s)
       )
	)
    (loss-condition (White Black) (pieces-remaining 1))
    (loss-condition (White Black) (pieces-remaining 0))
)

(define jump-capture
    ($1 (verify (and (not-position? c3) enemy?)) capture $1 (verify empty?) (add-partial capturing-move))
)
(variant
    (title "High Jump")
    (description "棋子可横或纵向移动一格。也可跳过对方一个棋子到后面相邻的空格，并捕杀被跳过的棋子。可以连跳。若棋子走到棋盘中心，则这个棋子不能被吃。\\吃光对手棋子为胜。")
    (history "This game, somewhat similar to Alquerque, is played on the same board
        as Seega.  It is popular in Somalia.")
    (strategy "As in most checkers variants, look for opportunities to make favorable
       exchanges of captures (two for one and three for two).   Pieces in the center
       are very mobile; pieces on the edges, though seeming less vulnerable to capture,
       are actually less mobile and easier to trap.")
    (players Black White)
    (turn-order Black White)
    (move-priorities capturing-move move-stone)
    (board-setup
        (Black (Kelb a1 b1 c1 d1 e1 a2 b2 c2 d2 e2 d3 e3))
        (White (Kelb a5 b5 c5 d5 e5 a4 b4 c4 d4 e4 a3 b3))
    )
    (piece
        (name Kelb)
	    (image White "images\Seega\WStone.bmp"
		       Black "images\Seega\BStone.bmp")
	    (help "棋子可直走一格，跳吃。")
        (moves
            (move-type capturing-move)
			 (jump-capture n)
             (jump-capture s)
             (jump-capture e)
             (jump-capture w)
            (move-type move-stone)
             (shift-orthoganally n w e)
             (shift-orthoganally s w e)
             (shift-orthoganally e n s)
             (shift-orthoganally w n s)
      )
	)
    (loss-condition (White Black) (pieces-remaining 0))
)
